package com.zhichat.web.controller;

import com.zhichat.service.GroupInfoService;
import com.zhichat.web.api.PageUtils;
import com.zhichat.web.api.R;
import com.zhichat.web.dto.AdminGroupQueryDTO;
import com.zhichat.web.vo.AdminGroupInfoVO;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * admin后台群组管理
 *
 * @Author: 团长九哥 https://space.bilibili.com/602197686
 * @CreateDate: 2024/11/22 10:40
 */
@Slf4j
@AllArgsConstructor
@RestController
@RequestMapping("/admin/group")
public class AdminGroupController {

    private final GroupInfoService groupInfoService;

    /**
     * 后台群组列表
     */
    @GetMapping("/list")
    public R<PageUtils<AdminGroupInfoVO>> groupListOfAdmin(@Validated AdminGroupQueryDTO adminGroupQueryDTO) {
        return R.success(groupInfoService.groupListOfAdmin(adminGroupQueryDTO));
    }

    /**
     * 后台群组列表 解散群
     */
    @GetMapping("/disband_group")
    public R<String> disbandGroup(@RequestParam("groupId") Long groupId, @RequestParam("groupOwnerId") Long groupOwnerId) {
        return R.status(groupInfoService.disbandGroupByAdmin(groupId, groupOwnerId));
    }
}
